﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Configuration;
using System.Text;

namespace TaskMessage.Mail
{
    /// <summary>
    /// Mail相关配置
    /// </summary>
    public class MailConfig
    {
        #region 实体对象
        /// <summary>
        /// 实体对象
        /// </summary>
        private static MailConfig _Instance;
        /// <summary>
        /// 锁变量
        /// </summary>
        private static object _Locker = new object();
        /// <summary>
        /// 单例对象
        /// </summary>
        public static MailConfig Instance
        {
            get
            {
                if (_Instance == null)
                {
                    lock (_Locker)
                    {
                        if (_Instance == null)
                            _Instance = new MailConfig();
                    }
                }

                return _Instance;
            }
        }
        #endregion

        #region Settings
        protected NameValueCollection _Settings = null;
        /// <summary>
        /// 配置节
        /// </summary>
        public NameValueCollection Settings
        {
            get
            {
                if (_Settings == null)
                {
                    _Settings = (NameValueCollection)ConfigurationManager.GetSection("MailConfig");
                }

                return _Settings;
            }
        }
        #endregion

        /// <summary>
        /// smtp服务器
        /// </summary>
        public string smtp
        {
            get
            {
                return this.Settings["smtp"];
            }
        }

        /// <summary>
        /// smtp服务器端口
        /// </summary>
        public string smtpport
        {
            get
            {
                return this.Settings["smtpport"];
            }
        }

        /// <summary>
        /// smtp服务器是否需要ssl
        /// </summary>
        public string smtpssl
        {
            get
            {
                return this.Settings["smtpssl"];
            }
        }

        /// <summary>
        /// 是否需要登入认证
        /// </summary>
        public string auth
        {
            get
            {
                return this.Settings["auth"];
            }
        }

        /// <summary>
        /// 认证用户名
        /// </summary>
        public string authUserName
        {
            get
            {
                return this.Settings["authUserName"];
            }
        }

        /// <summary>
        /// 认证密码
        /// </summary>
        public string authUserpwd
        {
            get
            {
                return this.Settings["authUserpwd"];
            }
        }

        /// <summary>
        /// 发送间隔 毫秒
        /// </summary>
        public string sendsleeptime
        {
            get
            {
                return this.Settings["sendsleeptime"];
            }
        }

        /// <summary>
        /// 发送标题
        /// </summary>
        public string title
        {
            get
            {
                return this.Settings["title"];
            }
        }

        /// <summary>
        /// 发信人
        /// </summary>
        public string formname
        {
            get
            {
                return this.Settings["formname"];
            }
        }

        /// <summary>
        /// 发信人邮件地址
        /// </summary>
        public string formid
        {
            get
            {
                return this.Settings["formid"];
            }
        }


        /// <summary>
        /// 读取及操作数据类
        /// </summary>
        public string DBClassName
        {
            get
            {
                return this.Settings["DBClassName"];
            }
        }

        /// <summary>
        /// 数据连接
        /// </summary>
        public string DataMssqlConn
        {
            get
            {
                return this.Settings["DataMssqlConn"];
            }
        }
        


    }
}
